using HKB.Common;
using System;
using System.Data;
using System.Web;
using System.Xml;
namespace HKB.Web
{
	public class SiteConfigBll : HoWave_Root
	{
		private string DataPath = "";
		public SiteConfigBll()
		{
			this.DataPath = HttpContext.Current.Server.MapPath("~/") + this.InstallDir + "App_Data/SiteConfig.config";
		}
		public DataTable GetSiteConfig()
		{
			string text = this.AppPrefix + "HoWaveSiteConfig";
			DataTable result;
			if (HttpContext.Current.Cache[text] != null)
			{
				result = (DataTable)HttpContext.Current.Cache[text];
			}
			else
			{
				DataSet dataSet = new DataSet();
				dataSet.ReadXml(this.DataPath);
				DataTable dataTable = dataSet.Tables[0];
				DataTable table = dataSet.Tables["TemplateSetList"];
				dataTable.Merge(table);
				DataCache.SetCacheDepFile(text, dataTable, DataCache.siteconfigfile);
				result = dataTable;
			}
			return result;
		}
		public string GetSiteString(string config)
		{
			XmlDocument xmlDocument = new XmlDocument();
			xmlDocument.Load(this.DataPath);
			return xmlDocument.SelectSingleNode(config).InnerText;
		}
		public bool UpdateSiteConfig(string CloseSite, string CityArea, string CloseMessage, string SiteName, string SiteUrl, string InstallDir, string LogoUrl, string BannerUrl, string WebMasterName, string WebMasterEmail, string WebLiveSet, string CopyRight, string VersionType, string SiteKey, string AdminDir, string SystemSet, string GuestBookShowIP, string EnableLoginCheckCode, string TryLoginTimes, string LoginInterval, string LoginIPBan, string LoginIPAccess, string EnableReg, string RegPageSet, string EnableRegCode, string EnableEmailOnce, string EnablePasswordCheck, string RegBanEmail, string RegConfirm, string RegEmailContent, string RegProtocalContent, string RegPresent1, string RegPresent2, string RegPresent3, string RegPresent4, string RegNameSet, string RegNameMin, string RegNameMax, string RegBanName, string RegURLSet, string RegURl, string RegIPOnce, string RegSendMsg, string RegMsgContent, string RegAnswerCheck, string RegQuestion, string RegAnswer, string EnableRegSelectItem, string MailObject, string MailSmtpServer, string MailServerUserName, string MailServerPassWord, string MailServerFrom, string GuestBookEnable, string UploadType, int UploadPicmaxSize, string UploadVideoType, int UploadVidmaxSize, string GuestBookEnableVistor, string GuestBookCheckCode, string GuestBookCheck, string HLIntegration, string DomainName, string SecurityKey, string AdminSecurityKey, string MessageOfOrderConfirm, string MessageOfReceiveMoney, string MessageOfRefund, string MessageOfDeliver, string MessageOfSendCard, string MessageOfConfrimEmail, string MessageOfConfrimPassword, string SamllPic_DefaultWidth, string SamllPic_DefaultHieght, string Wartermark_Type, string Wartermark_Text, string Wartermark_FontFamily, string Wartermark_FontWeight, string Watermark_PhotoUrl, string Watermark_PhotoAlpha, string Watermark_Position, string Watermark_PositionX, string Watermark_PositionY, string MetaKeywords, string MetaDescription, string otherTitle, string TemplateDir, string SiteSpecialDir, string AlipayConfig, string AlipayPartnerID, string AlipayKey, string ShopRootUrl, string IsUserSecUrl, int RegisterScope, int LoginScope, int GroupScope, int PromotionScope, int TransparentScope, int Charge_Count, int Cash_Count, decimal Cash_Money_Min, decimal Cash_Money_Max)
		{
			DataSet dataSet = new DataSet();
			dataSet.ReadXml(this.DataPath);
			DataTable dataTable = dataSet.Tables[0];
			DataRow dataRow = dataTable.Rows[0];
			dataRow["CloseSite"] = CloseSite;
			dataRow["CityArea"] = CityArea;
			dataRow["CloseMessage"] = CloseMessage;
			dataRow["SiteName"] = SiteName;
			dataRow["SiteUrl"] = SiteUrl;
			dataRow["InstallDir"] = this.InstallDir;
			dataRow["LogoUrl"] = LogoUrl;
			dataRow["BannerUrl"] = BannerUrl;
			dataRow["WebMasterName"] = WebMasterName;
			dataRow["WebMasterEmail"] = WebMasterEmail;
			dataRow["WebLiveSet"] = WebLiveSet;
			dataRow["CopyRight"] = CopyRight;
			dataRow["VersionType"] = VersionType;
			dataRow["SiteKey"] = SiteKey;
			dataRow["AdminDir"] = AdminDir;
			dataRow["SystemSet"] = SystemSet;
			dataRow["GuestBookShowIP"] = GuestBookShowIP;
			dataRow["EnableLoginCheckCode"] = EnableLoginCheckCode;
			dataRow["TryLoginTimes"] = TryLoginTimes;
			dataRow["LoginInterval"] = LoginInterval;
			dataRow["LoginIPBan"] = LoginIPBan;
			dataRow["LoginIPAccess"] = LoginIPAccess;
			dataRow["EnableReg"] = EnableReg;
			dataRow["RegPageSet"] = RegPageSet;
			dataRow["EnableRegCode"] = EnableRegCode;
			dataRow["EnableEmailOnce"] = EnableEmailOnce;
			dataRow["EnablePasswordCheck"] = EnablePasswordCheck;
			dataRow["RegBanEmail"] = RegBanEmail;
			dataRow["RegConfirm"] = RegConfirm;
			dataRow["RegEmailContent"] = RegEmailContent;
			dataRow["RegProtocalContent"] = RegProtocalContent;
			dataRow["RegPresent1"] = RegPresent1;
			dataRow["RegPresent2"] = RegPresent2;
			dataRow["RegPresent3"] = RegPresent3;
			dataRow["RegPresent4"] = RegPresent4;
			dataRow["RegNameSet"] = RegNameSet;
			dataRow["RegNameMin"] = RegNameMin;
			dataRow["RegNameMax"] = RegNameMax;
			dataRow["RegBanName"] = RegBanName;
			dataRow["RegURLSet"] = RegURLSet;
			dataRow["RegURl"] = RegURl;
			dataRow["RegIPOnce"] = RegIPOnce;
			dataRow["RegSendMsg"] = RegSendMsg;
			dataRow["RegMsgContent"] = RegMsgContent;
			dataRow["RegAnswerCheck"] = RegAnswerCheck;
			dataRow["RegQuestion"] = RegQuestion;
			dataRow["RegAnswer"] = RegAnswer;
			dataRow["EnableRegSelectItem"] = EnableRegSelectItem;
			dataRow["MailObject"] = MailObject;
			dataRow["MailSmtpServer"] = MailSmtpServer;
			dataRow["MailServerUserName"] = MailServerUserName;
			if (!string.IsNullOrEmpty(MailServerPassWord))
			{
				dataRow["MailServerPassWord"] = MailServerPassWord;
			}
			dataRow["MailServerFrom"] = MailServerFrom;
			dataRow["GuestBookEnable"] = GuestBookEnable;
			dataRow["GuestBookEnableVistor"] = GuestBookEnableVistor;
			dataRow["GuestBookCheckCode"] = GuestBookCheckCode;
			dataRow["GuestBookCheck"] = GuestBookCheck;
			dataRow["HLIntegration"] = HLIntegration;
			dataRow["DomainName"] = DomainName;
			dataRow["SecurityKey"] = SecurityKey;
			dataRow["AdminSecurityKey"] = AdminSecurityKey;
			dataRow["UploadType"] = UploadType;
			dataRow["UploadPicmaxSize"] = UploadPicmaxSize.ToString();
			dataRow["UploadVideoType"] = UploadVideoType;
			dataRow["UploadVidmaxSize"] = UploadVidmaxSize.ToString();
			dataRow["MessageOfOrderConfirm"] = MessageOfOrderConfirm;
			dataRow["MessageOfReceiveMoney"] = MessageOfReceiveMoney;
			dataRow["MessageOfRefund"] = MessageOfRefund;
			dataRow["MessageOfDeliver"] = MessageOfDeliver;
			dataRow["MessageOfSendCard"] = MessageOfSendCard;
			dataRow["MessageOfConfrimEmail"] = MessageOfConfrimEmail;
			dataRow["MessageOfConfrimPassword"] = MessageOfConfrimPassword;
			dataRow["SamllPic_DefaultWidth"] = SamllPic_DefaultWidth;
			dataRow["SamllPic_DefaultHieght"] = SamllPic_DefaultHieght;
			dataRow["Wartermark_Type"] = Wartermark_Type;
			dataRow["Wartermark_Text"] = Wartermark_Text;
			dataRow["Wartermark_FontFamily"] = Wartermark_FontFamily;
			dataRow["Wartermark_FontWeight"] = Wartermark_FontWeight;
			dataRow["Watermark_PhotoUrl"] = Watermark_PhotoUrl;
			dataRow["Watermark_PhotoAlpha"] = Watermark_PhotoAlpha;
			dataRow["Watermark_Position"] = Watermark_Position;
			dataRow["Watermark_PositionX"] = Watermark_PositionX;
			dataRow["Watermark_PositionY"] = Watermark_PositionY;
			dataRow["MetaKeywords"] = MetaKeywords;
			dataRow["otherTitle"] = otherTitle;
			dataRow["MetaDescription"] = MetaDescription;
			dataRow["TemplateDir"] = TemplateDir;
			dataRow["SiteSpecialDir"] = SiteSpecialDir;
			dataRow["AlipayConfig"] = AlipayConfig;
			dataRow["IsUserSecUrl"] = IsUserSecUrl;
			dataRow["ShopRootUrl"] = ShopRootUrl;
			dataRow["RegisterScope"] = RegisterScope;
			dataRow["LoginScope"] = LoginScope;
			dataRow["GroupScope"] = GroupScope;
			dataRow["PromotionScope"] = PromotionScope;
			dataRow["TransparentScope"] = TransparentScope;
			dataRow["Charge_Count"] = Charge_Count;
			dataRow["Cash_Count"] = Cash_Count;
			dataRow["Cash_Money_Min"] = Cash_Money_Min;
			dataRow["Cash_Money_Max"] = Cash_Money_Max;
			if (string.IsNullOrEmpty(AlipayPartnerID))
			{
				dataRow["AlipayPartnerID"] = "";
			}
			else
			{
				dataRow["AlipayPartnerID"] = AlipayPartnerID.Trim();
			}
			if (string.IsNullOrEmpty(AlipayKey))
			{
				dataRow["AlipayKey"] = "";
			}
			else
			{
				dataRow["AlipayKey"] = AlipayKey.Trim();
			}
			for (int i = 0; i < dataTable.Columns.Count; i++)
			{
				if (string.IsNullOrEmpty(dataRow[i].ToString()))
				{
					dataRow[i] = "";
				}
			}
			try
			{
				dataSet.WriteXml(this.DataPath);
			}
			catch (Exception ex)
			{
				this.WriteErrMsg("", ex.Message.ToString(), "");
			}
			HttpContext.Current.Cache.Remove(this.AppPrefix + "HoWaveSiteConfig");
			return true;
		}
		public bool UpdateTemplateSet(string UserReg, string Login, string Passport, string ShowProduct, string Sell, string ProductCompare, string CategoryList, string ProductList, string ShopList, string ShopBuy, string ShopIndex, string Index, string SpecialDefault, string Browseoffer, string SearchProduct, string Article, string ArticleList, string ShopReview, string ShopIntro, string MemberIndex, string IdentifySuccess, string IdentifyCompany, string IdentifyUser, string IdentifyAgree, string IdentifyChoose, string PublishPreview, string Announce, string CommonShopIndex, string SeniorShopIndex, string ClassChoose, string SaleProduct, string EditProduct, string IdentifyAlert, string SearchShop, string ShopAllMessage, string RequestProduct, string ShopingCar, string AdminError, string AdminSuccess, string ShopError, string ShopSuccess, string MemberError, string MemberSuccess)
		{
			DataSet dataSet = new DataSet();
			dataSet.ReadXml(this.DataPath);
			DataTable dataTable = dataSet.Tables["TemplateSetList"];
			DataRow dataRow = dataTable.Rows[0];
			if (UserReg != "" && UserReg != null)
			{
				dataRow["UserReg"] = UserReg;
			}
			if (Login != "" && Login != null)
			{
				dataRow["Login"] = Login;
			}
			if (Passport != "" && Passport != null)
			{
				dataRow["Passport"] = Passport;
			}
			if (ShowProduct != "" && ShowProduct != null)
			{
				dataRow["ShowProduct"] = ShowProduct;
			}
			if (Sell != "" && Sell != null)
			{
				dataRow["Sell"] = Sell;
			}
			if (ProductCompare != "" && ProductCompare != null)
			{
				dataRow["ProductCompare"] = ProductCompare;
			}
			if (Browseoffer != "")
			{
				dataRow["Browseoffer"] = Browseoffer;
			}
			if (PublishPreview != "" && PublishPreview != null)
			{
				dataRow["PublishPreview"] = PublishPreview;
			}
			if (EditProduct != "" && EditProduct != null)
			{
				dataRow["EditProduct"] = EditProduct;
			}
			if (SaleProduct != "")
			{
				dataRow["SaleProduct"] = SaleProduct;
			}
			if (ClassChoose != "")
			{
				dataRow["ClassChoose"] = ClassChoose;
			}
			if (RequestProduct != "")
			{
				dataRow["RequestProduct"] = RequestProduct;
			}
			if (CategoryList != "" && CategoryList != null)
			{
				dataRow["CategoryList"] = CategoryList;
			}
			if (ProductList != "" && ProductList != null)
			{
				dataRow["ProductList"] = ProductList;
			}
			if (ShopBuy != "" && ShopBuy != null)
			{
				dataRow["ShopBuy"] = ShopBuy;
			}
			if (Index != "")
			{
				dataRow["Index"] = Index;
			}
			if (SpecialDefault != "")
			{
				dataRow["SpecialDefault"] = SpecialDefault;
			}
			if (SearchProduct != "")
			{
				dataRow["SearchProduct"] = SearchProduct;
			}
			if (SearchShop != "")
			{
				dataRow["SearchShop"] = SearchShop;
			}
			if (Article != "")
			{
				dataRow["Article"] = Article;
			}
			if (ArticleList != "")
			{
				dataRow["ArticleList"] = ArticleList;
			}
			if (Announce != "")
			{
				dataRow["Announce"] = Announce;
			}
			if (ShopReview != "")
			{
				dataRow["ShopReview"] = ShopReview;
			}
			if (ShopIntro != "")
			{
				dataRow["ShopIntro"] = ShopIntro;
			}
			if (SeniorShopIndex != "")
			{
				dataRow["SeniorShopIndex"] = SeniorShopIndex;
			}
			if (CommonShopIndex != "")
			{
				dataRow["CommonShopIndex"] = CommonShopIndex;
			}
			if (ShopAllMessage != "")
			{
				dataRow["ShopAllMessage"] = ShopAllMessage;
			}
			if (ShopList != "" && ShopList != null)
			{
				dataRow["ShopList"] = ShopList;
			}
			if (ShopIndex != "" && ShopIndex != null)
			{
				dataRow["ShopIndex"] = ShopIndex;
			}
			if (MemberIndex != "")
			{
				dataRow["MemberIndex"] = MemberIndex;
			}
			if (IdentifySuccess != "")
			{
				dataRow["IdentifySuccess"] = IdentifySuccess;
			}
			if (IdentifyCompany != "")
			{
				dataRow["IdentifyCompany"] = IdentifyCompany;
			}
			if (IdentifyUser != "")
			{
				dataRow["IdentifyUser"] = IdentifyUser;
			}
			if (IdentifyAgree != "")
			{
				dataRow["IdentifyAgree"] = IdentifyAgree;
			}
			if (IdentifyChoose != "")
			{
				dataRow["IdentifyChoose"] = IdentifyChoose;
			}
			if (IdentifyAlert != "")
			{
				dataRow["IdentifyAlert"] = IdentifyAlert;
			}
			if (ShopingCar != "")
			{
				dataRow["ShopingCar"] = ShopingCar;
			}
			if (AdminError != "")
			{
				dataRow["AdminError"] = AdminError;
			}
			if (AdminSuccess != "")
			{
				dataRow["AdminSuccess"] = AdminSuccess;
			}
			if (ShopError != "")
			{
				dataRow["ShopError"] = ShopError;
			}
			if (ShopSuccess != "")
			{
				dataRow["ShopSuccess"] = ShopSuccess;
			}
			if (MemberError != "")
			{
				dataRow["MemberError"] = MemberError;
			}
			if (MemberSuccess != "")
			{
				dataRow["MemberSuccess"] = MemberSuccess;
			}
			try
			{
				dataSet.WriteXml(this.DataPath);
			}
			catch (Exception ex)
			{
				this.WriteErrMsg("", Language.GetAdminMsg("Common/EditFail", ex.Message.ToString()), "");
			}
			HttpContext.Current.Cache.Remove(this.AppPrefix + "HoWaveSiteConfig");
			return true;
		}
		public bool UpDateConfigNode(string nodeName, string values)
		{
			XmlHelper xmlHelper = new XmlHelper();
			xmlHelper.Load(this.DataPath);
			xmlHelper.SetNodeText(nodeName, values);
			xmlHelper.Save(this.DataPath);
			HttpContext.Current.Cache.Remove(this.AppPrefix + "HoWaveSiteConfig");
			return true;
		}
	}
}
